<template>
  <div class="content">
    <div class="header">
      <div class="infoCard">
        <div class="card_top">
          <dir class="top_l">
            <img :src="userInfo.userHead" alt="">
            <div>
              <span>{{userInfo.userName}}</span>
              <span v-if="userInfo.userGexing">{{userInfo.userGexing}}</span>
              <span v-if="!userInfo.userGexing">暂无个性签名</span>
            </div>
          </dir>
          <dir class="top_r" @click="toUserInfo">
            <div class="infoAndGo">
              <span>个人信息</span>
              <img src="/img/personal/infoGo.png" alt="">
            </div>
          </dir>
        </div>
        <!-- 分割线 -->
        <div class="card_mid">
          <van-divider />
        </div>
        <div class="card_bottom">
          <div class="bottom_l">
            <span>部门/校区：</span><span>{{userInfo.userDep}}</span>
          </div>
          <div class="bottom_r">
            <span>职位：</span><span>{{userInfo.userJob}}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="list">
      <!-- 我的奖章 -->
      <div class="myMedal" @click="toMedalDetail">
        <div class="myMedal_l">
          <img src="/img/personal/medal.png" alt="">
          <span>我的奖章</span>
        </div>
        <div class="myMedal_r">
          <!-- <span class="medal_r_con">
            kfasjfiwafagjajfjkajfaefalkgjkagkakfakgvaniajjafaalfkajfkalfeawjfagakfjkajfkajfalgahguiahfkhalfagmkagjglja
          </span> -->
          <img src="/img/circle/next.png" alt="">
        </div>
      </div>
      <!-- 任务 -->
      <div class="myTask">
        <!-- 备课视频任务 -->
        <div class="myTaskCon" @click="toVideoTask">
          <div class="together">
            <div class="myTaskCon_t">
              <div class="imgBro">
                <img src="/img/my/task.png" alt="">
                <div class="redCircle" v-if="flag1"></div>
              </div>
              <span>备课视频任务</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        <!-- 手写教案任务 -->
        <div class="myTaskCon" @click="toHandleTask">
          <div class="together">
            <div class="myTaskCon_t">
              <div class="imgBro">
                <img src="/img/my/task.png" alt="">
                <div class="redCircle" v-if="flag2"></div>
              </div>
              <span>手写教案任务</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        <!-- 教室图片任务 -->
        <div class="myTaskCon" @click="toRoomTask">
          <div class="together">
            <div class="myTaskCon_t">
              <div class="imgBro">
                <img src="/img/my/task.png" alt="">
                <div class="redCircle" v-if="flag3"></div>
              </div>
              <span>教室图片任务</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <!-- <div class="myTaskCon_b">
            <van-divider />
          </div> -->
        </div>
      </div>
      <!-- 审批 -->
      <div class="myApprove" @click="toVideoApprove">
        <div class="myApprove_l">
          <img src="/img/my/myApprove.png" alt="">
          <span>精彩视频审批</span>
        </div>
        <div class="myApprove_r">
          <img src="/img/circle/next.png" alt="">
        </div>
      </div>
      <!-- 设置 -->
      <div class="myTask">
        <!-- 消息 -->
        <div class="myTaskCon" @click="toMessage">
          <div class="together">
            <div class="myTaskCon_t">
              <img class="messageImg" src="/img/my/message.png" alt="">
              <span>消息</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        
        <!-- 我的积分 -->
        <div class="myTaskCon" @click="toIntegral">
          <div class="together">
            <div class="myTaskCon_t">
              <img class="jifenImg" src="/img/my/jifen.png" alt="">
              <span>我的积分</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        <!-- 意见反馈 -->
        <div class="myTaskCon" @click="toOpations">
          <div class="together">
            <div class="myTaskCon_t">
              <img class="messageImg" src="/img/my/message.png" alt="">
              <span>意见反馈</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        <!-- 设置 -->
        <div class="myTaskCon" @click="toSetting">
          <div class="together">
            <div class="myTaskCon_t">
              <img class="settingImg" src="/img/my/setting.png" alt="">
              <span>设置</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <div class="myTaskCon_b">
            <van-divider />
          </div>
        </div>
        <!-- 退出登录 -->
        <div class="myTaskCon" @click="logOut">
          <div class="together">
            <div class="myTaskCon_t">
              <img class="logoutImg" src="/img/my/logout.png" alt="">
              <span>退出登录</span>
            </div>
            <div class="myTaskCon_m">
              <img src="/img/circle/next.png" alt="">
            </div>
          </div>
          <!-- <div class="myTaskCon_b">
            <van-divider />
          </div> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  data() {
    return {
      userInfo: {},
      userName: "",
      userHead: "",
      userDep: "",
      userGexing: "",
      flag1: false,
      flag2: false,
      flag3: false,
    };
  },
  mounted() {
    this.userInfoShow();
    this.queryData1();
    this.queryData2();
    this.queryData3();
  },
  methods: {
    ...mapMutations({ changeActive: "changeActive" }),
    toOpations(){
      this.$router.push('/opations');
    },
    // 查询是否有备课视频任务
    queryData1() {
      (async () => {
        const { data } = await this.get(
          "/approve/queryApproveByStatusAndUserId",
          {
            userId: localStorage.getItem("id"),
            renwuType: "备课视频",
            status: 0,
            pageSize: 6,
            pageNum: 1,
          }
        );
        if (data.items.length > 0) {
          this.flag1 = true;
        } else {
          this.flag1 = false;
        }
      })();
    },
    // 查询是否有手写教案任务
    queryData2() {
      (async () => {
        const { data } = await this.get(
          "/approve/queryApproveByStatusAndUserId",
          {
            userId: localStorage.getItem("id"),
            renwuType: "手写教案",
            status: 0,
            pageSize: 6,
            pageNum: 1,
          }
        );
        if (data.items.length > 0) {
          this.flag2 = true;
        } else {
          this.flag2 = false;
        }
      })();
    },
    // 查询是否有上课图片任务
    queryData3() {
      (async () => {
        const { data } = await this.get(
          "/approve/queryApproveByStatusAndUserId",
          {
            userId: localStorage.getItem("id"),
            renwuType: "上课图片",
            status: 0,
            pageSize: 6,
            pageNum: 1,
          }
        );
        if (data.items.length > 0) {
          this.flag3 = true;
        } else {
          this.flag3 = false;
        }
      })();
    },
    // 查询用户信息
    userInfoShow() {
      (async () => {
        const { data } = await this.get("/user/userInfoShow", {
          userId: localStorage.getItem("id"),
        });
        this.userInfo = data;
      })();
    },
    // 个人信息
    toUserInfo() {
      this.$router.push({
        path: "/userInfo",
        query: {
          userDep: this.userInfo.userDep,
          userJob: this.userInfo.userJob,
          userHead: this.userInfo.userHead,
          userGexing: this.userInfo.userGexing,
        },
      });
    },
    // 我的奖章
    toMedalDetail() {
      this.$router.push("/medalDetail");
    },
    // 备课视频任务
    toVideoTask() {
      this.$router.push("/videoTask");
    },
    // 手写教案任务
    toHandleTask() {
      this.$router.push("/handleTask");
    },
    // 教室图片任务
    toRoomTask() {
      this.$router.push("/roomTask");
    },
    // 精彩视频审批
    toVideoApprove() {
      this.$router.push("/videoApproval");
    },
    // 消息
    toMessage() {
      this.$router.push("/Message");
    },
    // 我的积分
    toIntegral() {
      this.$router.push("/Integral");
    },
    // 设置
    toSetting() {
      this.$router.push("/Setting");
    },
    // 退出登录
    logOut() {
      this.$dialog
        .confirm({
          title: "退出登录",
          message: "是否确认退出登录",
        })
        .then(() => {
          localStorage.clear();
          this.$router.push("/login");
          this.changeActive("/dashborad/home");
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  width: 100%;
  height: 100%;
  background-color: #f7f9fa;
  .header {
    width: 7.5rem;
    height: 2.83rem;
    background-image: url("../../../public/img/my/my_bg.png");
    background-size: 100% 100%;
    position: relative;
    .infoCard {
      width: 7.02rem;
      height: 2.66rem;
      background: #ffffff;
      box-shadow: 0px 0.07rem 0.14rem 0.01rem rgba(93, 93, 93, 0.04);
      border-radius: 0.15rem 0.15rem 0 0;
      position: absolute;
      top: 0.44rem;
      left: 0.24rem;
      .card_top {
        .top_l {
          display: flex;
          align-items: center;
          margin: 0.42rem 0 0 0.3rem;
          img {
            width: 0.92rem;
            height: 0.92rem;
            border-radius: 50%;
            margin-right: 0.19rem;
          }
          div span:first-child {
            display: block;
            font-size: 0.32rem;
            font-family: PingFang SC;
            font-weight: bold;
            color: #333333;
          }
          div span:last-child {
            display: block;
            font-size: 0.22rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: #9a9a9a;
            width: 4.2rem;
          }
        }
        .top_r {
          width: 1.31rem;
          height: 0.44rem;
          background: #2d9dff;
          border-radius: 0.21rem 0px 0px 0.22rem;
          position: absolute;
          top: 0.6rem;
          right: 0;
          display: flex;
          align-items: center;
          .infoAndGo {
            display: flex;
            align-items: center;
            padding-left: 0.18rem;
            span {
              display: block;
              height: 0.44rem;
              line-height: 0.44rem;
              margin-right: 0.07rem;
              font-size: 0.2rem;
              font-family: PingFang SC;
              font-weight: 400;
              color: #ffffff;
            }
            img {
              width: 0.08rem;
              height: 0.14rem;
            }
          }
        }
      }
      .card_mid {
        padding: 0 0.3rem;
        .van-divider {
          margin-bottom: 0;
        }
      }
      .card_bottom {
        font-size: 0.26rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
        display: flex;
        align-items: center;
        .bottom_l span:last-child {
          font-weight: normal;
        }
        .bottom_r span:last-child {
          font-weight: normal;
        }
        .bottom_l {
          width: 3.5rem;
          height: 0.81rem;
          line-height: 0.81rem;
          text-align: center;
          border-right: 0.01rem #e7e7e7 solid;
          padding-left: 0.22rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .bottom_r {
          width: 3.5rem;
          height: 0.81rem;
          line-height: 0.81rem;
          // text-align: center;
          padding-left: 0.22rem;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
  .list {
    font-size: 0.1rem;
    margin-top: 0.6rem;
    .myMedal {
      width: 7.5rem;
      height: 1rem;
      background: #ffffff;
      // box-shadow: 0rem 0.07rem 0.15rem 0.01rem rgba(93, 93, 93, 0.04);
      border-radius: 0.15rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 0.24rem;
      box-sizing: border-box;
      .myMedal_l {
        display: flex;
        align-items: center;
        img {
          width: 0.5rem;
          height: 0.5rem;
        }
        span {
          font-size: 0.3rem;
          font-family: PingFang SC;
          font-weight: bold;
          color: #333333;
          margin-left: 0.16rem;
        }
      }
      .myMedal_r {
        // margin-left: 0.37rem;
        // width: 4.7rem;
        // overflow-x: auto;
        // .medal_r_con {
        //   font-size: 0.3rem;
        //   font-family: PingFang SC;
        //   font-weight: 400;
        //   color: #7d7d7d;
        //   display: inline-block;
        //   height: 0.9rem;
        //   line-height: 0.9rem;
        // }
        img {
          width: 0.14rem;
          height: 0.26rem;
        }
      }
    }
    .myTask {
      margin-top: 0.2rem;

      .myTaskCon {
        width: 7.5rem;
        padding: 0 0.24rem;
        box-sizing: border-box;
        background-color: #fff;
        .together {
          width: 100%;
          height: 1rem;
          display: flex;
          align-items: center;
          justify-content: space-between;
          .myTaskCon_t {
            display: flex;
            align-items: center;
            .imgBro {
              position: relative;
              img {
                width: 0.36rem;
                height: 0.4rem;
              }
              .redCircle {
                width: 0.14rem;
                height: 0.14rem;
                background-color: #f00;
                border-radius: 50%;
                position: absolute;
                top: -0.07rem;
                right: -0.07rem;
              }
            }
            .messageImg {
              width: 0.36rem;
              height: 0.34rem;
            }
            .jifenImg {
              width: 0.38rem;
              height: 0.34rem;
            }
            .settingImg {
              width: 0.36rem;
              height: 0.36rem;
            }
            .logoutImg {
              width: 0.35rem;
              height: 0.36rem;
            }
            span {
              font-size: 0.3rem;
              font-family: PingFang SC;
              font-weight: 500;
              color: #333333;
              margin-left: 0.22rem;
            }
          }
          .myTaskCon_m {
            img {
              width: 0.14rem;
              height: 0.26rem;
            }
          }
        }
        .myTaskCon_b {
          .van-divider {
            margin: 0 !important;
          }
        }
      }
    }
    .myApprove {
      width: 7.5rem;
      height: 1rem;
      background: #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 0.24rem;
      box-sizing: border-box;
      margin-top: 0.2rem;
      .myApprove_l {
        display: flex;
        align-items: center;
        img {
          width: 0.36rem;
          height: 0.37rem;
        }
        span {
          font-size: 0.3rem;
          font-family: PingFang SC;
          font-weight: 500;
          color: #333333;
          margin-left: 0.22rem;
        }
      }
      .myApprove_r {
        img {
          width: 0.14rem;
          height: 0.26rem;
        }
      }
    }
  }
}
</style>